package MiniEditeur;

public class Buffer {
	
	//----------------Arguments--------------------------------------------------------------------------
	
	private StringBuffer texte;
	private int debutSelection;
	private int finSelection;
	private int tailleTexte;
	private PressePapier PP;
	
	//----------------Constructeur----------------------------------------------------------------------
	
	public Buffer(StringBuffer t, PressePapier p){
		this.texte = t;
		this.tailleTexte = texte.length();
		this.PP = p;
	}
	
	//----------------Methodes--------------------------------------------------------------------------
	
	public void selectionner(int debS, int finS)
	{
		this.debutSelection = debS;
		this.finSelection = finS;			
	}
	
	public void inserer(String t)
	{
		this.texte = this.texte.replace(debutSelection, finSelection, t);
	}
	
	public void effacer()
	{
		this.texte = this.texte.replace(debutSelection, finSelection, "");	
	}
	
	public void coller()
	{
		this.texte = this.texte.replace(debutSelection, finSelection, PP.lire());
			
	}
	
	public void copier()
	{
		PP.ecrire(this.texte.substring(debutSelection,finSelection));
			
	}

}
